package demo.fristserice.controller;/**
 * @author wqf
 * @date 2019/11/13 13:53
 */


import demo.fristserice.common.Demo;
import demo.fristserice.common.result.Result;
import demo.fristserice.service.DemoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version : 1.0
 * @ClassName: DemoController
 * @Auther: wqf
 * @Date: 2019/11/13 13:53
 */

@RestController
@RequestMapping("/demo")
@CrossOrigin
public class DemoController {

    @Autowired
    DemoService demoService;
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @ResponseBody  // 返回 Json 数据
    @PostMapping("/get")
    private List getTest(){
        try {
            System.out.println("你妹的");
            return demoService.getTest();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
    @ResponseBody
    @PostMapping("/getlist")
    private Result getTestlist(@RequestBody Demo demo){
        try {
            System.out.println("你妹的");
            logger.info("挖槽，无情");
            return Result.success(demoService.getTestlist(demo));
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}
